<template>
	<view>
<u-navbar
		:background="background" title="提现记录"
		title-color="#ffffff"
		back-icon-color="#ffffff"
		:borderBottom="false"
		>
		</u-navbar>
		<view class="recharge-bg">
			
		</view>
		<view class="history-content">
			<view class="history-title">
				<view class="history-title-l">
					事项
				</view>
				<view class="history-title-l">
					金额
				</view>
			</view>
			<template v-if="list.length>0">
				<block v-for="(item,ind) in list" :key="ind">
					<view class="list" @tap.stop="detail(item)">
						<view class="list-l">
							<view>-{{item.number}}</view>
							<text>{{i18n.withdrawal + i18n.quantity}}</text>
						</view>
						<view class="list-r">
							<view>{{item.status==3?((index==0?i18n.recharge:i18n.withdrawal) + i18n.success):item.status==1?'打包中':i18n.turnDown}}</view>
							<text>{{item.create_time}}</text>
						</view>
					</view>
				</block>
			</template>
			<template v-else>
				<view class="no-data">
					<image src="../../static/imgs/nodata.png" mode="widthFix" lazy-load></image>
					<view class="text">
						{{i18n.nodata}}~
					</view>
				</view>
			</template>
		</view>
		
		<load v-if="showload"></load>
	</view>
</template>

<script>
	var timer;
	import {mapGetters,mapMutations} from "vuex";
	import {pageto, showToast, fetch, forceUpdate} from '@/common/js/util.js';
	import load from '@/components/common/load.vue';
	export default {
		components:{
			load
		},
		data() {
			return {
				background:'#ffffff',
				index: 0,
				showload:false,
				page:1,
				curInfo:{},
				list:[],
				isCheck:false,
				background: "linear-gradient(to right ,#F5C249, #947222)",
			}
		},
		computed:{
			i18n() {
				return this.$t('message')
			},
			...mapGetters([
				'getRequestUrl',
				'getLangType',
				'getLogin',
				'getLoginInfo'
			]),
		},
		onLoad() {
			this.page =1;
			this.list =[]
			this.index=1
			this.getHistory();
		},
		onPullDownRefresh() {
			this.page =1;
			this.list =[]
			this.getHistory();
		},
		onReachBottom() {
			let _self = this
		    if (timer != null) {
		        clearTimeout(timer);
		    }
		    timer = setTimeout(function() {
				if(_self.index!=2){
					_self.getMoreHistory();
				}else{
					_self.getMoreEchaglist()
				}
				uni.stopPullDownRefresh()
		    }, 1000);
		},
		methods:{
			getHistory(){
				
				
				let data = {
					id:this.getLoginInfo.id,
					token:this.getLoginInfo.token,
					page:this.page,
					rows:50,
					type:2
				}
				this.showload = true;
				if(this.isCheck) return
				this.isCheck  = true;
				fetch('/api/wallet/history',data,'post')
					.then(res=>{
						this.isCheck  = false;
						this.showload = false;
						if(res.data.data.data.length==0){
							return
						}
						if(res.data.code){
							this.page++;
							this.list = res.data.data.data;
						}
					})
					.catch(error=>{
						this.isCheck  = false;
						this.showload = false;
						// console.log(og(error);
					})
			},
			getMoreHistory(){
				let data = {
					id:this.getLoginInfo.id,
					token:this.getLoginInfo.token,
					page:this.page,
					rows:10,
					type:2,
				}
				if(this.isCheck) return
				this.isCheck  = true;
				this.showload = true;
				fetch('/api/wallet/history',data,'post')
					.then(res=>{
						this.isCheck  = false;
						this.showload = false;
						if(res.data.data.data.length==0){
							return
						}
						if(res.data.code){
							this.page++;
							this.list = this.list.concat(res.data.data.data);
						}
					})
					.catch(error=>{
						this.isCheck  = false;
						this.showload = false;
						// console.log(og(error);
					})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/common/scss/variable.scss';
	.history-title{
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 26rpx;
		color: $white;
		
		.history-title-l{
			line-height: 110rpx;
		}
		border-bottom: 1rpx solid #9A9CB8;
	}
	.recharge-bg{
		background:linear-gradient(to right ,#F5C249, #947222) ;
		height: 320rpx;
		width: 750rpx;
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		z-index: 2;
	}
	.history-content{
		position: absolute;
		left: 0;
		top: 108rpx;
		right: 0;
		height: 93.4vh;
		z-index: 8;
		background: #21242D;
		border-top-left-radius: 40rpx;
		border-top-right-radius: 40rpx;
		padding: 0 66rpx;
	}
	.nav-top{
		color: $black;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 30rpx;
		// #ifdef APP-PLUS
		width: 750rpx;
		// #endif
		// #ifdef MP-WEIXIN
		width: 650rpx;
		// #endif
		.nav-top-t{
			line-height: 88rpx;
			font-size: 32rpx;
			flex: 1;
			text-align: center;
		}
		.nav-top-l{
			width: 60rpx;
			height: 60rpx;
			margin-right: 60rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background: #ffffff;
			line-height: 80rpx;
			box-shadow: -5rpx 5rpx 10rpx rgba($color: #000000, $alpha: .4);
			position: relative;
			// color: $white;
			border-radius: 10rpx;
			&.active{
				box-shadow: -5rpx 5rpx 10rpx rgba($color: #000000, $alpha: .4) inset;
				&::before{
					content: "";
					left: 0;
					bottom: 0;
					z-index: -1;
					position: absolute;
					width: 100%;
					height: 100%;
					border-radius: 10rpx;
					box-shadow: 5rpx -5rpx 10rpx rgba($color: #ffffff, $alpha: .1) inset;
				}
			}
			&::before{
				content: "";
				left: 0;
				bottom: 0;
				z-index: -1;
				position: absolute;
				width: 100%;
				height: 100%;
				border-radius: 10rpx;
				box-shadow: 5rpx -5rpx 10rpx rgba($color: #ffffff, $alpha: .1);
			}
		}
		.nav-top-t-r{
			width: 120rpx;
			 font-size: 26rpx;
		}
	}
	.no-data{
		margin-top: 130upx;
		text-align: center ;
		image{
			margin: 0 auto;
			width: 220upx;
			height: 220upx;
			flex-shrink: 0;
		}
		.text{
			color: #6c7079;
			line-height:50rpx;
		}
	}
	.history-nav{
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: $white;
		padding-top: 20upx;
		view{
			flex: 1;
			text-align: center;
			color: $black;
			line-height: 72upx;
			font-size: 34upx;
			&.active{
				position: relative;
				color: $theme-color;
				&::after{
					content:"";
					left: 50%;
					bottom: 0;
					width: 100upx;
					height: 3upx;
					background-color: $theme-color;
					position: absolute;
					transform: translateX(-50%);
				}
			}
		}
	}
	.list{
		display: flex;
		justify-content: space-between;
		align-items: center;
		// margin: 22upx 30upx 0;
		// border-radius: 10upx;
		// padding: 40upx;
		// background-color: $white;
		border-bottom: 1rpx solid #9A9CB8;
		padding: 30rpx 0 26rpx;
		.list-l{
			view{
				font-size: 36upx;
				font-weight: bold;
				color: #15D288;
			}
			text{
				color: $light_gray1;
				font-size: 26upx;
			}
		}
		.list-r{
			text-align: right;
			view{
				color: $white;
				font-size: 30upx;
			}
			text{
				color: $light_gray1;
				font-size: 26upx;
			}
		}
	}
</style>
